/*
 Navicat Premium Data Transfer

 Source Server         : 192.168.68.129
 Source Server Type    : SQL Server
 Source Server Version : 11002100
 Source Host           : 192.168.68.129:3308
 Source Catalog        : mes_taipinggang
 Source Schema         : dbo

 Target Server Type    : SQL Server
 Target Server Version : 11002100
 File Encoding         : 65001

 Date: 11/10/2023 08:53:01
*/


-- ----------------------------
-- Table structure for alarm_parameter_settings
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[alarm_parameter_settings]') AND type IN ('U'))
	DROP TABLE [dbo].[alarm_parameter_settings]
GO

CREATE TABLE [dbo].[alarm_parameter_settings] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [mes_device_id] bigint  NULL,
  [xinkong_device_id] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL,
  [point_id] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL,
  [point_name] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL,
  [custom_parameter_name] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [parameter_type] tinyint  NULL,
  [alarm] bit  NULL,
  [alarm_type] tinyint  NULL,
  [alarm_message] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL,
  [alarm_frequency] tinyint  NULL,
  [interval_time] int  NULL,
  [remarks] nvarchar(300) COLLATE Chinese_PRC_CI_AS  NULL,
  [show_order] int DEFAULT ((0)) NULL
)
GO

ALTER TABLE [dbo].[alarm_parameter_settings] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'mes系统中设备id',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'mes_device_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'信控设备id',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'xinkong_device_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'对应信控pointId',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'point_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'对应信控pointName',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'point_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'自定义参数名称',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'custom_parameter_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数类型：0/开关量 1/变量',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'parameter_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否报警： 0/否 1/是',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'alarm'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警类型：0/fasle 1/true 2/变化 3/限值报警 4/连续报警',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'alarm_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警参数设置，此字段为一个json字符串
开关量：[{value:true,msg:"报警文本"}]，[{value:"true--false":msg:"报警文本"},{value:"false--true":msg:"报警文本"}]
变量：
限值报警[{maxValue:"",msg:"报警文本"},{minValue:"",msg:"报警文本"}]
连续报警[{value:"",msg:"报警文本"},{value:"",msg:"报警文本"},{value:"",msg:"报警文本"},{value:"",msg:"报警文本"}]',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'alarm_message'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警频率：0/实时报警 1/间隔报警',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'alarm_frequency'
GO

EXEC sp_addextendedproperty
'MS_Description', N'间隔频率，单位 秒',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'interval_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'remarks'
GO

EXEC sp_addextendedproperty
'MS_Description', N'显示顺序，开关量和变量分别排序',
'SCHEMA', N'dbo',
'TABLE', N'alarm_parameter_settings',
'COLUMN', N'show_order'
GO


-- ----------------------------
-- Table structure for alarm_record_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[alarm_record_info]') AND type IN ('U'))
	DROP TABLE [dbo].[alarm_record_info]
GO

CREATE TABLE [dbo].[alarm_record_info] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [alarm_status] tinyint DEFAULT ((0)) NULL,
  [alarm_date] datetime2(0)  NULL,
  [device_id] bigint  NULL,
  [parameter_id] bigint  NULL,
  [parameter_type] tinyint  NULL,
  [alarm_value] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [limit_value] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [alarm_message] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [alarm_notifier] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [alarm_notifier_name] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [handler] bigint  NULL,
  [handle_date] datetime2(0)  NULL,
  [handle_description] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [alarm_type] tinyint  NULL,
  [alarm_frequency] tinyint  NULL,
  [limit_type] tinyint  NULL,
  [immediately_value] decimal(8,2)  NULL,
  [change_type] tinyint  NULL,
  [alarm_pic] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[alarm_record_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警状态（0：未处理1：已处理）',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'alarm_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警时间',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'alarm_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备ID',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'device_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数ID',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'parameter_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警类型0：开关量1：参数',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'parameter_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警值',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'alarm_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'限值',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'limit_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警文本',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'alarm_message'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警通知人',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'alarm_notifier'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警通知人昵称',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'alarm_notifier_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'处理人',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'handler'
GO

EXEC sp_addextendedproperty
'MS_Description', N'处理时间',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'handle_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'处理描述',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'handle_description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警类型：0/fasle 1/true 2/变化 3/限值报警 4/连续报警',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'alarm_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警频率：0/实时报警 1/间隔报警',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'alarm_frequency'
GO

EXEC sp_addextendedproperty
'MS_Description', N'限值报警 限值类型：0小于限值 1大于限值',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'limit_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'连续报警报警值',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'immediately_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开关量报警类型 0:true--fale 1:false--true',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'change_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'处理图片',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info',
'COLUMN', N'alarm_pic'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警记录表',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_info'
GO


-- ----------------------------
-- Table structure for alarm_record_time
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[alarm_record_time]') AND type IN ('U'))
	DROP TABLE [dbo].[alarm_record_time]
GO

CREATE TABLE [dbo].[alarm_record_time] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [alarm_record_id] bigint  NULL,
  [alarm_status] tinyint DEFAULT ((0)) NULL,
  [alarm_date] datetime2(0)  NULL,
  [device_id] bigint  NULL,
  [parameter_id] bigint  NULL,
  [parameter_type] tinyint  NULL,
  [alarm_type] tinyint  NULL,
  [alarm_frequency] tinyint  NULL,
  [limit_type] tinyint  NULL,
  [immediately_value] decimal(8,2)  NULL,
  [change_type] tinyint  NULL
)
GO

ALTER TABLE [dbo].[alarm_record_time] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警记录表ID',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'alarm_record_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警状态（0：未处理1：已处理）',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'alarm_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警时间',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'alarm_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备ID',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'device_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数ID',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'parameter_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警类型0：开关量1：参数',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'parameter_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警类型：0/fasle 1/true 2/变化 3/限值报警 4/连续报警',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'alarm_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警频率：0/实时报警 1/间隔报警',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'alarm_frequency'
GO

EXEC sp_addextendedproperty
'MS_Description', N'限值报警 限值类型：0小于限值 1大于限值',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'limit_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'连续报警报警值',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'immediately_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开关量报警类型 0:true--fale 1:false--true',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time',
'COLUMN', N'change_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警记录表',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_time'
GO


-- ----------------------------
-- Table structure for alarm_record_user_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[alarm_record_user_info]') AND type IN ('U'))
	DROP TABLE [dbo].[alarm_record_user_info]
GO

CREATE TABLE [dbo].[alarm_record_user_info] (
  [record_id] bigint  NOT NULL,
  [user_id] bigint  NOT NULL,
  [send_flag] tinyint DEFAULT ((0)) NULL
)
GO

ALTER TABLE [dbo].[alarm_record_user_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警记录ID',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_user_info',
'COLUMN', N'record_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户ID',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_user_info',
'COLUMN', N'user_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否发送过消息 0：待发送1：已发送',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_user_info',
'COLUMN', N'send_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警记录用户信息',
'SCHEMA', N'dbo',
'TABLE', N'alarm_record_user_info'
GO


-- ----------------------------
-- Table structure for mes_device
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[mes_device]') AND type IN ('U'))
	DROP TABLE [dbo].[mes_device]
GO

CREATE TABLE [dbo].[mes_device] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [dept] bigint  NULL,
  [work_team] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [code] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [type] bigint  NULL,
  [name] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [mark] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [model] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [header] bigint  NULL,
  [repair_header] bigint  NULL,
  [upkeep_header] bigint  NULL,
  [operator] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [power] varchar(500) COLLATE Chinese_PRC_CI_AS DEFAULT NULL NULL,
  [cnc_system] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [other_paramters] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [producer] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [produce_year] int  NULL,
  [produce_moth] int  NULL,
  [attachments] varchar(2000) COLLATE Chinese_PRC_CI_AS  NULL,
  [description] varchar(2000) COLLATE Chinese_PRC_CI_AS  NULL,
  [creator] bigint  NULL,
  [gmt_create] datetime2(7) DEFAULT (getdate()) NULL,
  [gmt_modify] datetime2(7) DEFAULT (getdate()) NULL,
  [device_status] tinyint DEFAULT ((1)) NULL,
  [creator_dept] bigint  NULL,
  [creator_date] datetime2(7)  NULL,
  [is_capacity_device] tinyint  NULL,
  [is_acquisition_device] tinyint  NULL,
  [theoretical_processing_cycle] decimal(8,2)  NULL,
  [workshop_section] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [pictures] varchar(4000) COLLATE Chinese_PRC_CI_AS  NULL,
  [device_uuid] char(32) COLLATE Chinese_PRC_CI_AS  NULL,
  [qrcode_url] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [alarm_notifier] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [data_device_id] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL,
  [device_running_status] tinyint DEFAULT ((0)) NULL,
  [device_online] bit DEFAULT ((0)) NULL,
  [device_order] bigint  NULL,
  [tsp_device] bigint  NULL,
  [harbor_entry_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[mes_device] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'所属部门',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'班组Id',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'work_team'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备编号',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备类型',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备名称',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备代号',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'mark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'规格/型号',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'model'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备负责人',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'header'
GO

EXEC sp_addextendedproperty
'MS_Description', N'维修负责人',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'repair_header'
GO

EXEC sp_addextendedproperty
'MS_Description', N'保养负责人',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'upkeep_header'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作人',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'operator'
GO

EXEC sp_addextendedproperty
'MS_Description', N'功率',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'power'
GO

EXEC sp_addextendedproperty
'MS_Description', N'系统',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'cnc_system'
GO

EXEC sp_addextendedproperty
'MS_Description', N'其他参数',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'other_paramters'
GO

EXEC sp_addextendedproperty
'MS_Description', N'制造商',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'producer'
GO

EXEC sp_addextendedproperty
'MS_Description', N'制造年份',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'produce_year'
GO

EXEC sp_addextendedproperty
'MS_Description', N'制造月份',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'produce_moth'
GO

EXEC sp_addextendedproperty
'MS_Description', N'附件',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'attachments'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用途说明',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'制单人',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'creator'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'gmt_create'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'gmt_modify'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备状态（0：闲置1：启用）',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'device_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'制单部门',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'creator_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N' 制单日期',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'creator_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'产能设备 0否 1是',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'is_capacity_device'
GO

EXEC sp_addextendedproperty
'MS_Description', N'数据采集设备 0否 1是',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'is_acquisition_device'
GO

EXEC sp_addextendedproperty
'MS_Description', N'理论加工周期（单位min）',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'theoretical_processing_cycle'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工段（字典项）',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'workshop_section'
GO

EXEC sp_addextendedproperty
'MS_Description', N'图片附件',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'pictures'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备uuid',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'device_uuid'
GO

EXEC sp_addextendedproperty
'MS_Description', N'二维码地址',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'qrcode_url'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警通知人',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'alarm_notifier'
GO

EXEC sp_addextendedproperty
'MS_Description', N'数据设备id',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'data_device_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备运行状态（0：设备运行/设备启动1：设备异常2：设备掉线3：设备暂停）',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'device_running_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备在线状态 （0离线 1在线）',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'device_online'
GO

EXEC sp_addextendedproperty
'MS_Description', N'3D排序',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'device_order'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tsp设备',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'tsp_device'
GO

EXEC sp_addextendedproperty
'MS_Description', N'进港时间',
'SCHEMA', N'dbo',
'TABLE', N'mes_device',
'COLUMN', N'harbor_entry_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备台账表',
'SCHEMA', N'dbo',
'TABLE', N'mes_device'
GO


-- ----------------------------
-- Table structure for mes_device_type
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[mes_device_type]') AND type IN ('U'))
	DROP TABLE [dbo].[mes_device_type]
GO

CREATE TABLE [dbo].[mes_device_type] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [code] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [creator] bigint  NULL,
  [gmt_create] datetime2(7) DEFAULT (getdate()) NULL,
  [gmt_modify] datetime2(7) DEFAULT (getdate()) NULL,
  [type_name] varchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [category] tinyint  NULL,
  [parent_type] tinyint  NULL
)
GO

ALTER TABLE [dbo].[mes_device_type] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'mes_device_type',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'编码',
'SCHEMA', N'dbo',
'TABLE', N'mes_device_type',
'COLUMN', N'code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'mes_device_type',
'COLUMN', N'creator'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'mes_device_type',
'COLUMN', N'gmt_create'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'mes_device_type',
'COLUMN', N'gmt_modify'
GO

EXEC sp_addextendedproperty
'MS_Description', N'类型名称',
'SCHEMA', N'dbo',
'TABLE', N'mes_device_type',
'COLUMN', N'type_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数类型0:预置1:手动添加',
'SCHEMA', N'dbo',
'TABLE', N'mes_device_type',
'COLUMN', N'category'
GO

EXEC sp_addextendedproperty
'MS_Description', N'上级分类0:无组织1:有组织2:除尘及生产设备',
'SCHEMA', N'dbo',
'TABLE', N'mes_device_type',
'COLUMN', N'parent_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备类型表',
'SCHEMA', N'dbo',
'TABLE', N'mes_device_type'
GO


-- ----------------------------
-- Auto increment value for alarm_parameter_settings
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[alarm_parameter_settings]', RESEED, 27)
GO


-- ----------------------------
-- Primary Key structure for table alarm_parameter_settings
-- ----------------------------
ALTER TABLE [dbo].[alarm_parameter_settings] ADD CONSTRAINT [PK__alarm_pa__3213E83F45D4C436] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for alarm_record_info
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[alarm_record_info]', RESEED, 12)
GO


-- ----------------------------
-- Primary Key structure for table alarm_record_info
-- ----------------------------
ALTER TABLE [dbo].[alarm_record_info] ADD CONSTRAINT [PK__alarm_re__3213E83FFDFD627F] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for alarm_record_time
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[alarm_record_time]', RESEED, 4)
GO


-- ----------------------------
-- Primary Key structure for table alarm_record_time
-- ----------------------------
ALTER TABLE [dbo].[alarm_record_time] ADD CONSTRAINT [PK__alarm_re__3213E83F4ACFC351] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table alarm_record_user_info
-- ----------------------------
ALTER TABLE [dbo].[alarm_record_user_info] ADD CONSTRAINT [PK__alarm_re__545457AD27A446D6] PRIMARY KEY CLUSTERED ([record_id], [user_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for mes_device
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[mes_device]', RESEED, 30219)
GO


-- ----------------------------
-- Auto increment value for mes_device_type
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[mes_device_type]', RESEED, 10076)
GO

